﻿@using Pyramid.Models
@model IEnumerable<AttendanceDetail>
@{
	var master = (AttendanceMaster) ViewBag.Master;
}
<div class="pageContent">
	@using (Html.BeginForm("Edit", "Attendance", FormMethod.Post, new {id = "attendanceDetailForm"}))
	{
		@Html.Hidden("id", master.Id)
		@Html.Hidden("year", master.Year)
		@Html.Hidden("month", master.Month)
		@Html.Hidden("status", "1", new {id = "attendanceMasterStatus"})
		<div class="pageContentBar">
			<div class="title">@(string.Format("{0}年{1}月份考勤汇总数据", master.Year, master.Month))</div>
			<div>
				本月应出勤天数：@Html.TextBox("expectedDays", master.ExpectedDays, new {@class = "digits short"}) 天 &nbsp;&nbsp;&nbsp;&nbsp; 当前状态：@master.StatusString
			</div>
			@if (master.Status != (int) DataStatus.Submit)
			{
				<div class="toolbar">
					<div class="buttonActive">
						<div class="buttonContent">
							<button onclick=" return saveAttendanceDetails(); ">&nbsp;&nbsp;保存&nbsp;&nbsp;</button>
						</div>
					</div>
					<div class="buttonActive">
						<div class="buttonContent">
							<button onclick=" return submitAttendanceDetails(); ">&nbsp;&nbsp;提交&nbsp;&nbsp;</button>
						</div>
					</div>
				</div>
			}
		</div>
		<table class="table" width="100%" layouth="138">
			<thead>
				<tr>
					<th>@Html.DisplayNameFor(x => x.Staff.Code)</th>
					<th>@Html.DisplayNameFor(x => x.Staff.FullName)</th>
					<th>@Html.DisplayNameFor(x => x.Staff.Gender)</th>
					<th>@Html.DisplayNameFor(x => x.Staff.DepartmentId)</th>
					<th>@Html.DisplayNameFor(x => x.Staff.PositionId)</th>
					<th>@Html.DisplayNameFor(x => x.Staff.EntryDate)</th>
					<th>@Html.DisplayNameFor(x => x.ActualDays)</th>
				</tr>
			</thead>
			<tbody>
				@foreach (var m in Model)
				{
					<tr>
						<td>@m.Staff.Code</td>
						<td>@m.Staff.FullName</td>
						<td>@m.Staff.GenderString</td>
						<td>@m.Staff.Department.Name</td>
						<td>@m.Staff.Position.Name</td>
						<td>@m.Staff.EntryDate.ToString("yyyy-MM-dd")</td>
						<td>@Html.TextBox("actualDays_" + m.Staff.Id, m.ActualDays, new {@class = "digits", max = "30", min = "0"})</td>
					</tr>
				}
			</tbody>
		</table>
	}
</div>
<script>
	function saveAttendanceDetails() {
		var form = $("#attendanceDetailForm");
		$("#attendanceMasterStatus").val("1");
		return validateCallback(form, navTabAjaxDone);
	}

	function submitAttendanceDetails() {
		var form = $("#attendanceDetailForm");
		$("#attendanceMasterStatus").val("2");
		return validateCallback(form, navTabAjaxDone);
	}
</script>